#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
const int SIZE = 110;
vector<int> linkmap[SIZE];
int areb[SIZE];
int brea[SIZE];
bool used[SIZE];//b
int tot,outer;
int cnt=0;
void init();
void showlink();
void prework();
void showre();
void edmonds();
bool dfs(int);
int main()
{
    freopen("dat.in","r",stdin);
    freopen("dat.out","w",stdout);
   // cout << "Hello world!" << endl;
    init();
    //prework();
    edmonds();
    showre();
    return 0;
}
void edmonds(){
    int i;
    for (i=1;i<=outer;i++){
        if (areb[i]==-1){
            memset(used,false,sizeof(used));
            if (dfs(i)){
                cnt++;
            }
        }
    }
}
bool dfs(int node){
    int i;
    int len = linkmap[node].size();
    for (i=0;i<len;i++){
        int next = linkmap[node][i];
        if (!used[next]){
            used[next]=true;
            if (brea[next]==-1||dfs(brea[next])){
                areb[node]=next;
                brea[next]=node;
                return true;
            }
        }
    }
    return false;
}
void prework(){
    int i,j;
    memset(used,false,sizeof(used));
    for (i=1;i<=outer;i++){
        int len = linkmap[i].size();
        for (j=0;j<len;j++){
            int node = linkmap[i][j];
            if (!used[node]){
                used[node]=true;
                areb[i]=node;
                brea[node]=i;
                cnt++;
                break;
            }
        }
    }
}
void showre(){
    printf("%d\n",cnt);
    int i;
    for (i=1;i<=outer;i++){
        if (areb[i]!=-1)
            printf("%d %d\n",i,areb[i]);
    }
}
void init(){
    int i;
    for (i=0;i<SIZE;i++){
        linkmap[i].clear();
    }
    scanf("%d%d",&outer,&tot);
    int a,b;
    while (true){
        scanf("%d%d",&a,&b);
        if (a==-1 && b==-1)
            break;
        linkmap[a].push_back(b);
        linkmap[b].push_back(a);
    }
    memset(areb,-1,sizeof(areb));
    memset(brea,-1,sizeof(brea));
    cnt=0;
    //showlink();
}
void showlink(){
    int i,j;
    for (i=1;i<=tot;i++){
        cout<<"node "<<i<<endl;
        for (j=0;j<linkmap[i].size();j++){
            printf("%d  ",linkmap[i][j]);
        }
        printf("\n");
    }
}
